package com.gbb.simple;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.gbb.simple.base.TitleFragmentActivity;
import com.gbb.simple.ui.DemoListActivity;
import com.gbb.simple.ui.PathDemoActivity;
import com.gbb.simple.ui.SwipeRefreshActivity;
import com.gbb.simple.ui.TouchEventActivity;
import com.gbb.simple.ui.WidgetStyleActivity;
import com.gbb.simple.ui.animation.AnimActivity;
import com.gbb.simple.ui.tabpager.TabViewPagerActivity;
import com.gbb.simple.ui.toggle.ToggleFragmentActivity;


public class MainActivity extends TitleFragmentActivity implements View.OnClickListener {


    @Override
    protected void onCreateAfter(Bundle savedInstanceState) {
        addLayout(R.layout.activity_main);

        findViewById(R.id.btn_swipeRefresh).setOnClickListener(this);
        findViewById(R.id.btn_tab_pager).setOnClickListener(this);
        findViewById(R.id.btn_toggleFragment).setOnClickListener(this);
        findViewById(R.id.btn_touch_event).setOnClickListener(this);
        findViewById(R.id.btn_test_listview).setOnClickListener(this);
        findViewById(R.id.btn_widget_style).setOnClickListener(this);
        findViewById(R.id.btn_anim_property).setOnClickListener(this);
        findViewById(R.id.btn_canvas_path).setOnClickListener(this);

        setTitle("主页测试");

        startService(getServiceIntent("value1"));

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                mContext.startService(getServiceIntent("value2"));
            }

        },3000);
    }

    private Intent getServiceIntent(String value) {
        Intent mIntent = new Intent(this,AsyncService.class);
        mIntent.putExtra("key",value);
        return mIntent;
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()) {

            case R.id.btn_swipeRefresh:
                startActivity(SwipeRefreshActivity.class);
                break;

            case R.id.btn_tab_pager:
                startActivity(TabViewPagerActivity.class);
                break;

            case R.id.btn_toggleFragment:
                startActivity(ToggleFragmentActivity.class);
                break;

            case R.id.btn_test_listview:
                startActivity(DemoListActivity.class);
                break;

            case R.id.btn_widget_style:
                startActivity(WidgetStyleActivity.class);
                break;

            case R.id.btn_anim_property:
                startActivity(AnimActivity.class);
                break;

            case R.id.btn_touch_event:
                startActivity(TouchEventActivity.class);
                break;

            case R.id.btn_canvas_path:
                startActivity(PathDemoActivity.class);
                break;

            default:

        }

    }

    @Override
    protected void initStatusBar() {
//        StatusBarUtil.setColor(this,getResources().getColor(R.color.app_tone));
    }
}
